const ua = navigator.userAgent.toLowerCase();
export default {
  mobile: () => {
    return 'ontouchstart' in window || ua.indexOf('touch') > -1 || ua.indexOf('mobile') > -1
  },
  safari: () => {
    return ua.indexOf('safari') > -1 && !window.chrome
  },
  app: () => {
    return ua.indexOf('yyzhuanapp') > -1
  },
  ie: () => {
    return !!window.ActiveXObject || 'ActiveXObject' in window
  },
  win: () => {
    return ua.indexOf('window') > -1 || ua.indexOf('win') > -1
  },
  ios: () => {
    return !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i)
  },
  ios_ver: () => {
    return ua.match(/cpu iphone os (.*?) like mac os/);
    // Number(browser.ios_ver()[1].replace('_','.')) 转成常见的数字版本号
  },
  android: () => {
    return ua.indexOf('android') > -1 || ua.indexOf('adr') > -1
  },
  android_ver: () => {
    return ua.match(/android (.*?);/);
  },
  wechat: () => {
    return ua.indexOf('micromessenger') > -1
  },
  
  pcWechart: () => {
    return ua.indexOf('windowswechat') > -1
  },
  
  qq: () => {
    return ua.match(/\sQQ/i) == 'qq'
  },
  
  weibo: () => {
    return ua.indexOf('weibo') > -1
  },
  
  iphone: () => {
    return ua.indexOf('iphone') > -1
  },
  
  ipad: () => {
    return ua.indexOf('ipad') > -1
  }
}